﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YakShaver.Contract;
namespace YakShaver.Tests.DummyObjects
{
   /// <summary>
   /// Dummy service of IAnalysisService used for testing the workflow.  
   /// </summary>
    public class IAnalysisDummyService : IAnalysisService
    {
        #region IAnalysisService Members

        public  int AnalysisCallCount = 0;
        public YakShaverWorkItem AnalyzeSubmittedWorkItem(ref IWorkItemDataContract workItemData)
        {
            YakShaverWorkItem returnItem = new YakShaverWorkItem();

            

            if (workItemData.PageId == "/home/test.aspx") // if we are testing... just so our first test goes green
            {
                // first time make in need intervention... second time make it ready.
                AnalysisCallCount++;
                returnItem.Component = "Testing";
                returnItem.Description = workItemData.Description;
                returnItem.WorkItemId = string.Empty;
                returnItem.WorkItemImpactType = AnalysisCallCount > 1 ? WorkItemImpactType.Medium : WorkItemImpactType.Unknown;
                returnItem.WorkItemType = AnalysisCallCount > 1 ? WorkItemType.Issue : WorkItemType.Unknown;
            }
            else if (workItemData.PageId == "/home/test2.aspx")
            {
                AnalysisCallCount++;
                returnItem.Component = "Testing";
                returnItem.Description = workItemData.Description;
                returnItem.WorkItemId = string.Empty;
                returnItem.WorkItemImpactType = WorkItemImpactType.Medium;
                returnItem.WorkItemType = WorkItemType.Issue;
            }
            else
                throw new NotImplementedException("Whoops!  Didn't expect this to happen!");

            return returnItem;
        }

       
        #endregion
    }
}
